<?php
$this->breadcrumbs = array(
    'Каталог'=>array('/katalog'),
    'Корзина'=>array('/korzina'),
    'Оформление заказа'
);

$this->setPageTitle('Оформление заказа');
?>

<?php $form=$this->beginWidget('CActiveForm', array(
    'id'=>'order-form',
    //'action'=>'/Order/default/addOrder',
    // Please note: When you enable ajax validation, make sure the corresponding
    // controller action is handling ajax validation correctly.
    // There is a call to performAjaxValidation() commented in generated controller code.
    // See class documentation of CActiveForm for details on this.
    'enableAjaxValidation'=>true,
    'errorMessageCssClass'=>'alert alert-danger'
)); ?>


       <h1><?php echo $this->getPageTitle(); ?></h1>

    <table class="table">
        <thead>
        <tr>
            <th>Название</th>
            <th>Цена</th>
            <th>Количество</th>
            <th>Общая стоимость</th>
        </tr>
        </thead>
        <tbody>
        <?php $total_price = 0; ?>
        <?php foreach($products as $product):?>
            <tr>
                <td><?php echo $product->title; ?></td>
                <td><?php echo number_format($product->price,0,'',' '); ?></td>
                <td><?php echo $cart[$product->id]?></td>
                <td><?php $total_price += ($cart[$product->id])*($product->price); echo number_format(($cart[$product->id])*($product->price),0,'',' '); ?></td>
            </tr>
        <?php endforeach; ?>
        <tr>
            <td>Итого: </td>
            <td></td>
            <td></td>
            <td><b><?php echo number_format($total_price,0,'',' '); ?> б.р.</b></td>
        </tr>
        </tbody>
    </table>

    <div class="">
            <h3>Ваши данные</h3>
        <p>Поля, помеченные <span class="required">*</span>, обязательны для заполнения:) </p>
    </div>

    <div class="block">
        <div class="">
            <?php echo $form->labelEx($model,'username'); ?>
        </div>
        <div class="">
            <?php echo $form->error($model,'username'); ?>
            <?php echo $form->textField($model,'username',array('size'=>60,'maxlength'=>256,'class'=>'form-control')); ?>
        </div>
    </div>
    <div class="block">
        <div class="">
            <?php echo $form->labelEx($model,'email'); ?>
        </div>
        <div class="">
            <?php echo $form->error($model,'email'); ?>
            <?php echo $form->textField($model,'email',array('size'=>60,'maxlength'=>256,'class'=>'form-control')); ?>
        </div>
    </div>
    <div class="block">
        <div class="">
            <?php echo $form->labelEx($model,'phone'); ?>
        </div>
        <div class="">
            <?php echo $form->error($model,'phone'); ?>
            <?php echo $form->textField($model,'phone',array('size'=>60,'maxlength'=>256,'class'=>'form-control')); ?>
        </div>
    </div>
    <div class="block">
        <div class="">
            <?php echo $form->labelEx($model,'address'); ?>
        </div>
        <div class="">
            <?php echo $form->error($model,'address'); ?>
            <?php echo $form->textField($model,'address',array('size'=>60,'maxlength'=>256,'class'=>'form-control')); ?>
        </div>
    </div>
    <div class="block">
        <div class="">
            <?php echo $form->labelEx($model,'comment'); ?>
        </div>
        <div class="">
            <?php echo $form->error($model,'comment'); ?>
            <?php echo $form->textField($model,'comment',array('size'=>60, 'class'=>'form-control')); ?>
        </div>
    </div>
    <?if(CCaptcha::checkRequirements() && Yii::app()->user->isGuest):?>
    <div class="block">
        <div class="">
        <?=CHtml::activeLabelEx($model, 'verifyCode')?>
        </div>
    </div>
    <div class="block">
        <div class="">
        <?$this->widget('CCaptcha', array(
            'buttonLabel' => CHtml::image(Yii::app()->request->baseUrl .'/images/design/icon_refresh.png'),
        ))?>
        </div>
    </div>
    <div class="block">
        <div class="">
        <?php echo $form->error($model,'verifyCode'); ?>
        <?=CHtml::activeTextField($model, 'verifyCode', array('class'=>'form-control'))?>
        </div>
    </div>
    <?endif?>


    <div class="buttons">
        <?php echo CHtml::link('Продолжить покупки', '/katalog', array('class' => 'btn btn-default')); ?>
        <?php echo CHtml::submitButton('Завершить оформление заказа', array('class' => 'btn btn-info')); ?>
    </div>

<?php $this->endWidget(); ?>
